package im.xz.cn.xiapvp;

import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;

public class qwq implements CommandExecutor {
    @Override
    public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s, @NotNull String[] strings) {
        Player player = (Player) commandSender;
        String name = player.getName();
        try {
            if (player.hasPermission("xzrui.xiapvp.use")) {
                try {
                    if (player.getDisplayName().contains("免战")) {
                        player.setDisplayName(name);
                        player.sendMessage(ChatColor.RED + "你已关闭免战状态！");
                    }else {
                        player.setDisplayName("免战 " + name);
                        player.sendMessage(ChatColor.GREEN + "你已开启免战状态。你下线重进会回复为默认状态。");
                    }
                }catch (NullPointerException ignore) {
                }
            }else {
                player.sendMessage(ChatColor.RED + "权限不足！如果你确信这是不应该的，请联系管理员并请他检查你是否拥有xzrui.xiapvp.use权限");
            }
        }catch (NullPointerException ignore) {
        }
        return false;
    }
}